package com.Model;

import java.util.List;

import com.UI.R;
import com.UI.RetrieveStudyInfo;
import com.UI.RetriveToDoInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
/**
 * 
 * @author Sugat Mahanti
 * 
 * For optimal ListView implementation 
 *
 */
public class StudyInfoAdapter extends ArrayAdapter<RetrieveStudyInfo>{

	private static List<RetrieveStudyInfo> records;
	public StudyInfoAdapter(Context context, int textViewResourceId,
			List<RetrieveStudyInfo> records) {
		super(context, textViewResourceId, records);
		this.records = records;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
             View v = convertView;
             if (v == null) {
                 LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                 v = vi.inflate(R.layout.study_info_row, null);
             }
             RetrieveStudyInfo studyinfo = records.get(position);
             if (studyinfo != null) {
                     TextView title_studyinfo = (TextView) v.findViewById(R.id.StudyInfoTitle);
                     title_studyinfo.setTextAppearance( getContext(), R.style.StudyInfoTitle );
                     
                     if (title_studyinfo != null) {
                     	title_studyinfo.setText(studyinfo.getName());                            
                     	}

                     TextView course_studyinfo = (TextView) v.findViewById(R.id.courseStudyInfo);
                     course_studyinfo.setTextAppearance( getContext(), R.style.StudyInfoCourse);
                     
                     if (course_studyinfo != null) {
                     	course_studyinfo.setText("(" + studyinfo.getCourse() + ")");      
                     }
                     
                     
                     TextView date_studyinfo = (TextView) v.findViewById(R.id.datetimeStudyInfo);
                     date_studyinfo.setTextAppearance( getContext(), R.style.StudyInfoTime );
                     
                     if (date_studyinfo != null) {
                     	date_studyinfo.setText(studyinfo.getDateTime());      
                     }          
                     

                      
                     
             
     }
             return v;
  }    
	
	
}
